<template>
	<!-- 累计分红 -->
	<view>
		<u-navbar title="累计分红" placeholder :autoBack="true" leftIconColor="#E6A5B4" bgColor="#FFFFFF"
			:titleStyle="titleStyle">

		</u-navbar>

		<view class="titleV">
			<view class="moneyTv">{{money}}</view>
			<view class="yuanTv">元</view>
		</view>

		<view class="leijiTv">累计分红</view>

		<view class="subTv">
			<view class="subTv1">时间</view>
			<view class="subTv2">金额</view>
			<view class="subTv3">描述</view>
		</view>

		<view>
			<scroll-view style="height: 100vh;" :scroll-y="true" @scroll="onScroll" :scroll-with-animation="true"
				:refresher-enabled="true" :refresher-triggered="triggered" @refresherrefresh="onDataList"
				refresher-default-style="white" @scrolltolower="scrolltolower">
				<view :class="key%2!=1?'subTvTo':'subTvs'" v-for="(item,key) in bonusData" :key="key">
					<view class="subTv4">{{item.createtime.substring(0,10)}}</view>
					<view class="subTv5">{{item.money}}</view>
					<view class="subTv6">{{item.memo}}</view>
				</view>
			</scroll-view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				titleStyle: {
					"color": "#ffffff"
				},
				bonusData: [],
				money: 0,
				mPage:1,
				scrollTop: 0,
				triggered: false,
				mRoleId:''
			}
		},
		onLoad(e) {
			this.money = e.money;
			this.mRoleId = e.id;
			this.getBonusList();
		},
		methods: {
			onDataList() {
				if (this.scrollTop == 0) {
					this.triggered = true;
					this.mPage = 1
					this.getBonusList()
				}
			},
			scrolltolower() { //上拉加载
				this.mPage++
				this.getBonusList()
			},
			onScroll(e) {
				this.scrollTop = e.detail.scrollTop
			},
			getBonusList() {
				this.$api.getBonusList({
					page:this.mPage,
					role_id:this.mRoleId
				}).then((res) => {
					
					if (this.mPage == 1) {
						this.bonusData = res.rows;
					} else {
						this.bonusData.push(...res.rows)
					}
					this.triggered = false;
				}).catch((e) => {
					this.triggered = false;
					uni.$u.toast(e.msg === undefined ? "请求失败" : e.msg)
				})
			},
		}
	}
</script>

<style lang="scss">
	.titleV {
		width: 100%;
		display: flex;
		justify-content: center;
		align-items: baseline;
		margin-top: 20rpx;

		.moneyTv {
			font-size: 60rpx;
			color: #CEF743;
		}

		.yuanTv {
			font-size: 32rpx;
			color: #FFFFFF;
		}
	}

	.leijiTv {
		width: 100%;
		display: flex;
		justify-content: center;
		font-size: 28rpx;
		color: #939393;
		margin-top: 10rpx;
	}

	.subTv {
		display: flex;
		align-items: center;
		margin-left: 30rpx;
		margin-right: 30rpx;
		background: #1F1F1F;
		margin-top: 72rpx;
		height: 80rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}


	.subTvs {
		display: flex;
		align-items: center;
		margin-left: 30rpx;
		margin-right: 30rpx;
		background: #1F1F1F;
		height: 80rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}

	.subTvTo {
		display: flex;
		align-items: center;
		margin-left: 30rpx;
		margin-right: 30rpx;
		background: #FFFFFF;
		height: 80rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
	}

	.subTv1 {
		flex: 2;
		color: #FFFFFF;
		font-size: 32rpx;
	}

	.subTv2 {
		flex: 1;
		color: #FFFFFF;
		font-size: 32rpx;
	}

	.subTv3 {
		flex: 1;
		color: #FFFFFF;
		font-size: 32rpx;
	}

	.subTv4 {
		flex: 2;
		color: #939393;
		font-size: 32rpx;
	}

	.subTv5 {
		flex: 1;
		color: #F07B7B;
		font-size: 32rpx;
	}

	.subTv6 {
		flex: 1;
		color: #939393;
		font-size: 32rpx;
	}
</style>
